package chatClient;

import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.PrintWriter;
import java.net.Socket;

import mappingBD.Synchronisation;



public class Reception implements Runnable {

	private Socket socket;
	private Synchronisation sync = null;
	public boolean authentifier = false;
	public Thread t2;
	
	public Reception(Socket s){
		
		this.socket = s;
	}
	
	public void run() {
		
			try {
				InputStream in = socket.getInputStream();
				ObjectInputStream objectInput = new ObjectInputStream(in);
				Synchronisation requeteRecu = (Synchronisation) objectInput.readObject();
				if (requeteRecu != null) {
					System.out.println("Vient de recevoir une Sync Côté client");
					sync = requeteRecu;
				}

			} catch (Exception e) {

				System.err.println("Le Serveur ne repond pas !");
				e.printStackTrace();
			}
		}

	//GETTERS AND SETTERS
	public Synchronisation getSync() {
		return sync;
	}

	public void setSync(Synchronisation sync) {
		this.sync = sync;
	}	
}
